import React, { Component } from 'react';
import { PageModal } from './PageModal';  // 模态框
import { PageListRadio } from './PageListRadio';  // 弹框的 单选列表
import { PageMessageList } from './PageMessageList'; //消息列表
import { PageSelectModal } from './PageSelectModal'; // 消息模块-头部模态框下拉
import { PageBtn } from './PageBtn'; // 按钮
import { PageHeadCloes } from './PageHeadCloes'; // 按钮
import { CommonHeaderLeft } from './CommonHeaderLeft'; // 头部左箭头
import { CommonHeaderRight } from './CommonHeaderRight'; // 头部右侧操作

export class Common extends Component {
	constructor(props) {
		super(props);
	}

	// 弹框
	_returnModal() {
		let { isVisible, demoData, modelClick, animationType, closeCallballFn } = this.props;
		return (
			<PageModal isVisible={isVisible} demoData={demoData} modelClick={modelClick} animationType={animationType} closeCallballFn={closeCallballFn} />
		)
	}
	//弹框中的列表单选
	_returnListRadio() {
		let { listData, selectIndex, title, selectCallBack } = this.props;
		return (
			<PageListRadio
				title={title}  //标题
				selectIndex={selectIndex}  // 默认选中  不选可以写-1
				listData={listData}  // 数据
				selectCallBack={selectCallBack}   // 点击回调
			/>
		)
	}
	//消息列表
	_returnMessageList() {
		let { title, number, imgUrl, callBack } = this.props;
		return (
			<PageMessageList title={title} number={number} imgUrl={imgUrl} callBack={callBack} />
		)
	}
	//
	_returnSelectModal() {
		let { data, allClick, styleList, styleBox, imgIndex, itemFn, styleOut } = this.props;
		return (
			<PageSelectModal data={data} allClick={allClick} itemFn={itemFn} imgIndex={imgIndex} styleOut={styleOut} styleBox={styleBox} styleList={styleList} />
		)
	}
	//按钮
	_returnBtn() {
		let { title, callBack, styleBtn } = this.props;
		return (
			<PageBtn title={title} callBack={callBack} styleBtn={styleBtn} />
		)
	}
	//顶部 关闭
	_returnHeadCloes() {
		let { callBack, imgStyle } = this.props;
		return (
			<PageHeadCloes callBack={callBack} imgStyle={imgStyle} />
		)
	}

	//_returnHeadCloes
	_returnHeadLeft() {
		let { onPress, color, imgStyle, ifHiddenTitle } = this.props;
		return (
			<CommonHeaderLeft onPress={onPress} color={color} imgStyle={imgStyle} ifHiddenTitle={ifHiddenTitle} />
		)
	}
	_returnHeadRight() {
		let { onPress, tintColor, imgStyle, ifHiddenTitle, rightText, rightIcon, rightTextStyle } = this.props;
		return (
			<CommonHeaderRight onPress={onPress} tintColor={tintColor} imgStyle={imgStyle} ifHiddenTitle={ifHiddenTitle} rightText={rightText} rightTextStyle={rightTextStyle} rightIcon={rightIcon} />
		)
	}

	render() {
		let { type } = this.props;
		if (type == 'modal') {
			return this._returnModal();
		} else if (type == 'listRadio') {
			return this._returnListRadio();
		} else if (type == 'messageList') {
			return this._returnMessageList();
		} else if (type == 'selectModal') {
			return this._returnSelectModal();
		} else if (type == 'bottom') {
			return this._returnBtn();
		} else if (type == 'headCloes') {
			return this._returnHeadCloes();
		} else if (type == 'headLeft') {
			return this._returnHeadLeft();
		} else if (type == 'headRight') {
			return this._returnHeadRight();
		} else {
			return null
		}
	}
}